import axios from "axios";

// 获取列表数据
export function getList(params) {
  return axios({
    url: "http://localhost:3001/data",
    method: "GET",
    params,
  });
}

// 新增任务
export function addTask(data) {
  return axios({
    url: "http://localhost:3001/data",
    method: "POST",
    data,
  });
}

// 获取详情
export function getTaskDetail(id) {
  return axios({
    url: `http://localhost:3001/data/${id}`,
    method: "GET",
  });
}

// 编辑任务
export function editTask(data) {
  return axios({
    url: `http://localhost:3001/data/${data.id}`,
    method: "PUT",
    data,
  });
}

// 删除任务
export function delTask(id) {
  return axios({
    url: `http://localhost:3001/data/${id}`,
    method: "DELETE",
  });
}

// 搜索任务
export function searchTask(name) {
  return axios({
    url: `http://localhost:3001/data/?name=${name}`,
    method: "GET",
  });
}
